import socket
import struct



s = socket.socket(socket.AF_INET,socket.SOCK_DGRAM)
#2.发送/接收数据
# send_msg0 = [int("66BB",16),30.12365,125.2654,34]
# send_msg0 = '1630.12365125.265434'
send_msg0 = struct.pack("<HddH", 22, 43.86228 , 125.34294, 34)
print(int("66BB",16))
print(send_msg0)
s.sendto(send_msg0, ("192.168.3.62", 8888))

# import bin.map as p
#
# list1 = [[0, 0], [10, 0], [10, 10], [0, 10]]
# l = p.order_point(list1)
# print(l)
# def cal_v(s_end):
#     # 初始化st图中t的步长
#     T = 0.01
#     # 选个大概的到达时间
#     t_end = s_end / 2
#     number_of_variable = int(t_end / T)
#     S_variable = cvxpy.Variable((1, int(number_of_variable)))
#     constrains = []
#     cost = 0.0
#
#     for i in range(1, number_of_variable - 1):
#         cost += cvxpy.sum_squares((S_variable[0, i + 1] + S_variable[0, i - 1] - 2 * S_variable[0, i]) / (T * T))
#         # constrains+=[S_variable[0,i]-S_variable[0,i-1]<=0.01*8]
#         constrains += [S_variable[0, i] >= S_variable[0, i - 1]]
#
#     cost += cvxpy.sum_squares((S_variable[0, number_of_variable - 2] - S_variable[0, number_of_variable - 3]) * 100000)
#
#     constrains += [S_variable[0, number_of_variable - 1] == S_variable[0, number_of_variable - 2]]
#     constrains += [S_variable[0, 0] == S_variable[0, 1]]
#     constrains += [S_variable[0, number_of_variable - 1] >= s_end]
#     constrains += [S_variable[0, 0] == 0]
#
#     prob = cvxpy.Problem(cvxpy.Minimize(cost), constrains)
#     print("题解的状态是", prob.solve(solver=cvxpy.OSQP))
#
#     print("s的序列是", S_variable.value)
#     # S_t_plan的S_t_plan[0]才是s的轨迹
#     S_t_plan = S_variable.value[0]
#     print(type(S_t_plan))
#     print(S_t_plan)
#     v=[]
#     for i in range(1,len(S_t_plan)):
#        v.append((S_t_plan[i]-S_t_plan[i-1])/T)
#     print(v)
#
# cal_v(100)
num = 0.11
decimal_len = len(str(num).split('.')[1])
print(decimal_len)
